<!DOCTYPE html>
<html lang="en">
  <head>
    <meta charset="UTF-8" />
    <meta name="viewport" content="width=device-width, initial-scale=1.0" />
    <title>Document</title>
  </head>
  <body>
    <a href="./b.html" onclick="event.preventDefault()">b.html</a>
    <a id="link" href="./a.html">a.html</a>

    <script>
      const link = document.getElementById("link");
      // link.onclick = function (e) {
      //   // 阻止默认行为
      //   e.preventDefault();
      //   alert("hello");
      // };
      link.addEventListener("click", (e) => {
        e.preventDefault();
      });
    </script>
  </body>
</html>
